package com.yiwenup.leetcode.top_interview_150;

/**
 * 文件描述
 *
 * @Project struct-algorithm
 * @Package com.yiwenup.leetcode.top_interview_150
 * @Author yiwenup
 * @Date 2024-12-18 22:29:03
 * @Description https://leetcode.cn/problems/ransom-note/description/?envType=study-plan-v2&envId=top-interview-150
 */
public class No0383 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] tmp = new int[26];
        for (int i = 0; i < ransomNote.length(); i++) {
            tmp[ransomNote.charAt(i) - 'a']++;
        }
        for (int i = 0; i < magazine.length(); i++) {
            tmp[magazine.charAt(i) - 'a']--;
        }
        for (int i = 0; i < 26; i++) {
            if (tmp[i] > 0) {
                return false;
            }
        }
        return true;
    }
}
